<!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
<stack>
<name>in</name>
<id>-1</id>
<cardCount>2</cardCount>
<cardID>2891</cardID>
<listID>2117</listID>
<cantModify><false /></cantModify>
<cantDelete><false /></cantDelete>
<cantAbort><false /></cantAbort>
<cardSize>
<width>384</width>
<height>256</height>
</cardSize>
<script>---- Misc useful stuff--Function RectSize TheRect-- returns the size of a rectangle, as a point.Put (item 3 of TheRect) - (item 1 of TheRect) into item 1 of TheSizePut (item 4 of TheRect) - (item 2 of TheRect) into item 2 of TheSizeReturn TheSizeEnd RectSizeFunction CreateGWorld PixelDepth, GWorldBounds-- common routine for creating a GWorld in temporary memory.Put 4 into useTempMemReturn NewGWorld(PixelDepth, GWorldBounds, "", "", useTempMem)End CreateGWorld---- File name parsing--Function FindNumberSuffix InName-- recognizes a name of the form “<anything><n>”-- where <n> is a sequence of one or more decimal digits,-- and returns the length of the part preceding the suffix.-- Returns empty if InName is not of this form.Put the length of InName into ThisPosRepeatIf ThisPos = 0 thenExit RepeatEnd IfGet char ThisPos of InNameIf it < "0" or it > "9" thenExit RepeatEnd IfSubtract 1 from ThisPosEnd RepeatIf ThisPos = the length of InName thenPut empty into ThisPosEnd IfReturn ThisPosEnd FindNumberSuffixFunction FileNamePart Pathname-- returns Pathname with prefixing volume and folder names stripped off.RepeatGet Offset(":", Pathname)If it = 0 or it = the length of Pathname thenExit RepeatEnd IfDelete char 1 to it of PathnameEnd RepeatReturn PathnameEnd FileNamePart---- Cleanup mechanism---- This makes sure that dynamic memory structures are-- freed if the user should prematurely terminate a-- handler with command-dot.---- Cleanup actions are accumulated in a global variable-- named “Cleanup”; another global “CleanupLevel” is-- is used to allow multiple redundant cleanup calls-- at the same level without accidentally invoking outer-- cleanup code.---- This system isn’t 100% foolproof (it’s still possible for-- the user to hit command-dot between the allocation of-- dynamic memory and the addition of a cleanup action to-- free it, for example). But it’s better than nothing.-- Trying to make things 100% foolproof would involve messing-- with CantAbort, which I’m reluctant to do at this stage.--On AddCleanup CleanupAction-- remembers another action to be performed when cleaning up-- at the current level.Global CleanupPut CleanupAction & return before CleanupEnd AddCleanupFunction PushCleanup-- starts another nested level of cleanup actions.-- Returns the new level count so caller knows how far-- to pop.Global Cleanup, CleanupLevelPut "Put" && Quoted(Cleanup) && "into Cleanup" into Cleanup -- restores previous level of cleanup.AddCleanup "Put" && CleanupLevel && "into CleanupLevel"Add 1 to CleanupLevelReturn CleanupLevel - 1End PushCleanupOn PopCleanup ToLevel-- performs cleanup actions, up to the specified level.-- ToLevel is the value that the caller obtained from the-- previous matching call to PushCleanup.Global Cleanup, CleanupLevelRepeat while ToLevel < CleanupLevelSet cursor to busyDo CleanupEnd RepeatEnd PopCleanup---- Common parts of conversion code-- (redirected to get around script length limitations)--On CreateMovieSend the params to card id 3783End CreateMovieOn AddMovieFrameSend the params to card id 3783End AddMovieFrameOn FinishedMovieSend the params to card id 3783End FinishedMovie---- Top-level handlers--On OpenStackGlobal Cleanup, CleanupLevelGet EnterMovies()If it is not empty thenAnswer "Error" && it && "initializing Movie Toolbox"End IfPut 0 into CleanupLevelEnd OpenStackOn CloseStackExitMoviesEnd CloseStackOn IdleGlobal CleanupLevelIf CleanupLevel > 0 thenAnswer "Leftover cleanup to do."PopCleanup 0End IfEnd Idle---- If you want brief descriptions of the XCMDs and XFCNs attached-- to this stack, have a look in the card script of the first card.-- The descriptions were moved there from here because of HyperCard’s-- limitations on the length of scripts.--</script>